/**
 *
 */
package jp.seraph.jsade.perceptor;

import jp.seraph.jsade.math.Angle;
import jp.seraph.jsade.sexpression.Node;

/**
 *
 *
 */
public class HearBulder implements PerceptorBuilder {

    /**
     *
     * @see jp.seraph.jsade.perceptor.PerceptorBuilder#build(jp.seraph.jsade.sexpression.Node)
     */
    public Perceptor build(Node aNode) {
        double tTime;
        String tStrAngle;
        String tMessage;

        tTime = aNode.getChildAsLeaf(1).getValueAsDouble();
        tStrAngle = aNode.getChildAsLeaf(2).getValue();
        tMessage = aNode.getChildAsLeaf(3).getValue();

        Angle tAngle = "self".equals(tStrAngle) ? null : Angle.createAngleAsDegree(Double.parseDouble(tStrAngle));

        return new HearPerceptor(tTime, tAngle, tMessage);
    }
}
